<template>
    <div class="base_template">
        <div class="title">基础设置</div>
        <div class="list">
            <div class="item">
                <div class="label">浏览器</div>
                <div class="value">
                    <div class="flex">
                        <app-select-button :buttonType="'ChroBrowser'" :data="state.formData.base.browser"
                            :formData="state.formData" :optios="state.map.Chrome" @click="store.getUserAgent()" />
                        <app-select-button :buttonType="'FireBrowser'" :data="state.formData.base.browser"
                            :formData="state.formData" :optios="state.map.Firefox" style="margin-left: 8px;"
                            @click="store.getUserAgent()" />
                    </div>
                    <div class="text" v-if="state.formData.base.browser.version == '-1'">基于 User Agent 匹配 {{
                        state.formData.base.browser.type }} 内核版本</div>
                </div>
            </div>

            <div class="item">
                <div class="label">操作系统</div>
                <div class="value" style="display: flex;">
                    <template v-for="item in state.map.operate" :key="item.value">
                        <app-button2 style="margin-right: 8px;"
                            v-if="!(state.formData.base.browser.type == 'FireBrowser' && (item.value == 'Android' || item.value == 'iOS' || item.value == 'macOS'))"
                            :class="state.formData.base.operate == item.value ? 'app-button2-active' : ''"
                            @click="store.getPhone(item.value)">
                            <div class="between">
                                <img :src="state.formData.base.operate == item.value ? item.icon_active : item.icon">
                                <div>{{ item.value }}</div>
                            </div>
                        </app-button2>
                    </template>

                </div>
            </div>

            <div class="item" v-if="state.formData.base.operate == 'Android' || state.formData.base.operate == 'iOS'">
                <div class="label">机型</div>
                <div class="value" style="display: flex;">
                    <el-select v-model="state.formData.base.model" placeholder="选择机型" style="width: 90%">
                        <el-option v-for="item in state.map.modelOptions" :key="item.value" :label="item.label"
                            :value="item.value" />
                    </el-select>
                </div>
            </div>
            <div class="item">
                <div class="label">User Agent</div>
                <div class="value">
                    <div class="flex">
                        <app-button3 v-model="state.formData.base.userAgent.type" :options="state.map.userAgentType" />
                    </div>
                    <div style="margin-top: 8px;width: 90%" class="flex">
                        <el-select v-model="state.formData.base.userAgent.inherit" multiple collapse-tags
                            placeholder="选择类型" style="width: 160px" @change="store.changeInherit">
                            <el-option label="全部" value="all" />
                            <el-option v-for="item in state.map.inheritOptions" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
const { store, state } = inject('preference_store')
</script>

<style lang="scss" scoped>
.base_template {
    display: flex;
    flex-direction: column;

    .title {
        margin: 16px 0;
        color: #1d2129;
        font-size: 14px;
    }
}

.list {
    display: flex;
    flex-direction: column;


    .item {
        margin-bottom: 16px;
        display: flex;
        flex-direction: column;

        .label {
            height: 30px;
            padding-bottom: 8px;
            color: #4e5969;
            font-size: 14px;
        }

        .value {
            .text {
                margin-top: 8px;
                color: #00000073;
                font-size: 14px;
            }

        }

    }

    .between {
        height: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;

        img {
            width: 18px;
            height: 18px;
            margin-right: 8px;
        }
    }

    .flex {
        display: flex;
    }

    .column {
        display: flex;
        flex-direction: column;
    }
}
</style>